package com.samoilovich.belarustoday.tech;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import com.samoilovich.belarustoday.Constants;
import com.samoilovich.belarustoday.R;
import com.samoilovich.belarustoday.basefragments.BaseFragmentActivity;
import com.samoilovich.belarustoday.basefragments.NewsContentBaseFragment;
import com.samoilovich.belarustoday.datemodel.CategoryModel;
import com.samoilovich.belarustoday.tech.fragments.TechCategoryFragment;
import com.samoilovich.belarustoday.tech.fragments.TechMainFragment;
import com.samoilovich.belarustoday.tools.Utility;

public class TechActivity extends BaseFragmentActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mUpdateButtonState = true;
		setContentView(R.layout.main);
        Utility.clearBackStack(this);
        Utility.initImageLoader(this);
		setTechMainFragment();
	}
	
	public void setTechMainFragment() {
		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

        TechMainFragment fragment = new TechMainFragment(TechActivity.this, Constants.TECH_MAIN_FRAGMENT_TAG);
		transaction.replace(R.id.frameLayout_content, fragment, Constants.TECH_MAIN_FRAGMENT_TAG);
		transaction.commit();
	}
	
	public void setTechCategoryFragment(CategoryModel categoryModel) {
		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

        TechCategoryFragment fragment = new TechCategoryFragment(TechActivity.this, categoryModel);
		transaction.replace(R.id.frameLayout_content2, fragment, Constants.TECH_CATEGORY_FRAGMENT_TAG);
		transaction.addToBackStack(null);
		transaction.commit();
	}
	
	public void setTechCategoryContentFragment(long newsId, String categoryName) {
		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

        NewsContentBaseFragment fragment = new NewsContentBaseFragment(TechActivity.this, newsId, categoryName);
		transaction.replace(R.id.frameLayout_content3, fragment, Constants.TECH_CATEGORY_CONTENT_FRAGMENT_TAG);
		transaction.addToBackStack(null);
		transaction.commit();
	}

}